package com.example.迭代器模式;

import java.util.Iterator;
import java.util.List;

/**
 * 汉堡包菜单迭代类
 */
public class PancakeHouseMenuIterator implements Iterator {
    List<Menu> menuItems;
    int position = 0;

    public PancakeHouseMenuIterator(List<Menu> menuItems) {
        this.menuItems = menuItems;
    }

    @Override
    public boolean hasNext() {
        if (position >= menuItems.size() || menuItems.get(position) == null) {
            return false;
        }

        return true;
    }

    @Override
    public Object next() {
        Menu menuItem = menuItems.get(position);
        position++;

        return menuItem;
    }
}
